package com.itheima.day02;

import java.util.Scanner;

public class Test03 {
    public static void main(String[] args) {
        //1. 键盘录入一个数
        Scanner sc = new Scanner(System.in);
        while (true) {
            System.out.println("请输入一个三位数整数:");
            int num = sc.nextInt();

            //2. 判断当前录入的数是否符合条件
            //2.1 先判断num是不是三位数
            if (num < 100 || num > 999) {
                System.out.println("输入有误!");
            } else {
                //2.2 是三位数,再来校验是否是水仙花数
                int ge = num % 10;
                int shi = num / 10 % 10;
                int bai = num / 10 / 10 % 10;

                if (ge * ge * ge + shi * shi * shi + bai * bai * bai == num) {
                    System.out.println(num + "是水仙花数");
                    break;
                } else {
                    System.out.println(num + "不是水仙花数");
                }
            }
        }
    }
}
